package org.rainy.gift.exception;

/**
 * 自定义一个业务异常类
 * 业务异常类,是用来区分业务异常(能够预知的异常)和系统异常
 */
public class BusinessException extends RuntimeException{

    private Integer code;

    public BusinessException() {
        super();
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    protected BusinessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public BusinessException(ResponseCode responseCode){
        super(responseCode.getMessage());
        this.code = responseCode.getCode();
    }

    public Integer getCode() {
        return code;
    }
}
